<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



namespace Mcm\RepasBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Validator\Constraints\Collection as Collection;
use Symfony\Component\Validator\Constraints\MaxLength as MaxLength;
/**
 * Description of BonType
 *
 * @author Gael
 */

class CoderepasType extends AbstractType {

    protected $repas;

    public function __construct($id){
        if($id!= 0){
            $this->repas = $id; 
        }
    }

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('repas','hidden',array('data'=>$this->repas))
                ->add('code','number',array('label' => 'Numero du code : '));
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        
        $cons = array();
        $cons=array_merge(array('bon'=> new MaxLength(8)),$cons);
        $collectionConstraint = new Collection($cons);
        $resolver->setDefaults(array(
            'validation_constraint'=>$collectionConstraint
        ));
    }

    public function getName() {
        return 'mcm_repasbundle_ajoutbontype';
    }

}


?>
